package helper

import (
	"log"
	"reflect"
)

// GetFieldValue 获取结构体字段
func GetFieldValue(structName interface{}, fieldName string) *reflect.Value {
	s := reflect.ValueOf(structName)

	if s.Kind() == reflect.Ptr {
		s = s.Elem()
	}
	if s.Kind() != reflect.Struct {
		log.Println("Check type error not Struct")
		return nil
	}
	f := s.FieldByName(fieldName)
	return &f
}
